import { RouteObject } from 'react-router-dom'
import Login from '../pages/login'
import NotFound from '../pages/not-found'
import LoginForm from '../pages/login/component/LoginForm'
import RegisterForm from '../pages/login/component/RegisterForm'
import AppLayout from '../layout'
import RegisterResult from '../pages/login/component/RegisterResult'
import { Suspense, lazy } from 'react'

const Home = lazy(() => import('../pages/home'))
const User = lazy(() => import('../pages/user'))

const routes: RouteObject[] = [

    {
        path: '/',
        element: <AppLayout />,
        children: [
            {
                path: '',
                element: <Suspense fallback={<h2>加载中....</h2>}>
                    <Home />
                </Suspense>
            },
            {
                path: 'user',
                element: <Suspense fallback={<h2>加载中....</h2>}>
                <User />
            </Suspense>
            },
        ],
    },
    {
        path: '/',
        element: <Login />,
        children: [
            {
                path: 'login',
                element: <LoginForm />
            },
            {
                path: 'register',
                element: <RegisterForm />,
            },
            {
                path: 'register/sucess',
                element: <RegisterResult />
            }
        ]
    },

    {
        path: '*',
        element: <NotFound />
    }
]

export {
    routes
}